/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;

import Exception.DBConnectionException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class DBUtils {
    
    public static Connection getConnection() throws DBConnectionException{
        try {
            //Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks", "sa", "123");
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String connectStr = Constants.CONNECT_STRING + Constants.MACHINE_HOST + ":" + Constants.MACHINE_PORT + ";databaseName=" + Constants.MACHINE_DB;
            Connection con =  DriverManager.getConnection(connectStr, Constants.USER_DB, Constants.PASSWORD_DB);
            return con;
        } catch (ClassNotFoundException ex) {
            
        }
        catch (SQLException ex) {
            
        } 
        return null;
    }
    
}
